package com.brycen.nio.selector;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

/**
 * 客户端主要就是接收服务端那边发过来的大量数据就行了
 */
public class WriteClient {
    public static void main(String[] args) throws IOException {
        SocketChannel channel = SocketChannel.open(new InetSocketAddress("localhost", 9999));

        //记录读取的总数
        int count = 0;
        while (true){
            //一次读取1M数据
            ByteBuffer buff = ByteBuffer.allocate(1024*1024);
            count += channel.read(buff);
            System.out.println(count);
            //清除缓冲区中的数据
            buff.clear();
        }
    }
}
